<script type="text/html" id="tpl_show_menu">
    <style type="text/css">
        .fui-startadv:before {background: <%style.background%>; opacity: <%style.opacity%>;}
    </style>
    <div class="fui-startadv <%params.style%>">
        <div class="inner">
            <%each data as item%>
                <img src="<%imgsrc item.imgurl%>" <%if params.style == 'default'%>style="height:100%"<%/if%>>
            <%/each%>
            <%if count(data)>1%>
                <div class="dots">
                    <%each data as item%>
                        <span></span>
                    <%/each%>
                </div>
            <%/if%>

            <%if (params.style =='default' && (params.autoclose > 1 || params.canclose > 0)) || (params.style=='small-bot' && params.canclose == 1) %>
                <div class="close-adv">
                    <div class="close-btn">
                        <%if params.style=='default'%>
                                <%if params.autoclose > 0%>
                                    <%params.autoclose%>
                                <%/if%>
                                <%if params.canclose > 0%>
                                    关闭
                                <%else%>
                                    秒
                                <%/if%>
                        <%/if%>
                    </div>
                </div>
            <%/if%>
        </div>
    </div>
</script>

<script type="text/html" id="tpl_edit_menu">

    <div class="form-group">
        <div class="col-sm-2 control-label">广告名称</div>
        <div class="col-sm-9">
            <input class="form-control diy-bind" data-bind="name" data-placeholder="未命名自定义菜单" placeholder="请输入名称" value="<%name%>">
            <div class="help-block">注意：广告名称是便于后台查找。</div>
        </div>
    </div>
    <div class="line"></div>

    <div class="form-group">
        <div class="col-sm-2 control-label">广告样式</div>
        <div class="col-sm-9">
            <label class="radio-inline"><input type="radio" name="style" value="default" class="diy-bind" data-bind-child="params" data-bind="style" data-bind-init="true" <%if params.style=='default'%>checked="checked"<%/if%>>样式一(全屏)</label>
            <label class="radio-inline"><input type="radio" name="style" value="small-bot" class="diy-bind" data-bind-child="params" data-bind="style" data-bind-init="true" <%if params.style=='small-bot'%>checked="checked"<%/if%>>样式二</label>
        </div>
    </div>

    <%if params.style == 'default'%>
        <div class="form-group">
            <div class="col-sm-2 control-label">定时关闭</div>
            <div class="col-sm-9">
                <label class="radio-inline"><input type="radio" name="autoclose" value="0" class="diy-bind" data-bind-child="params" data-bind="autoclose" data-bind-init="true" <%if params.autoclose==0%>checked="checked"<%/if%>>关闭</label>
                <label class="radio-inline"><input type="radio" name="autoclose" value="3" class="diy-bind" data-bind-child="params" data-bind="autoclose" data-bind-init="true" <%if params.autoclose==3%>checked="checked"<%/if%>>3秒</label>
                <label class="radio-inline"><input type="radio" name="autoclose" value="5" class="diy-bind" data-bind-child="params" data-bind="autoclose" data-bind-init="true" <%if params.autoclose==5%>checked="checked"<%/if%>>5秒</label>
                <label class="radio-inline"><input type="radio" name="autoclose" value="10" class="diy-bind" data-bind-child="params" data-bind="autoclose" data-bind-init="true" <%if params.autoclose==10%>checked="checked"<%/if%>>10秒</label>
                <label class="radio-inline"><input type="radio" name="autoclose" value="15" class="diy-bind" data-bind-child="params" data-bind="autoclose" data-bind-init="true" <%if params.autoclose==15%>checked="checked"<%/if%>>15秒</label>
            </div>
        </div>
    <%/if%>
            <div class="form-group">
                <div class="col-sm-2 control-label">手动关闭</div>
                <div class="col-sm-9">
                    <label class="radio-inline"><input type="radio" name="canclose" value="0" class="diy-bind" data-bind-child="params" data-bind="canclose" <%if params.canclose==0%>checked="checked"<%/if%>>关闭</label>
                    <label class="radio-inline"><input type="radio" name="canclose" value="1" class="diy-bind" data-bind-child="params" data-bind="canclose" <%if params.canclose==1%>checked="checked"<%/if%>>开启</label>
                </div>
            </div>

        <div class="line"></div>


    <%if params.style!='default'%>
        <div class="form-group">
            <div class="col-sm-2 control-label">广告背景</div>
            <div class="col-sm-9">
                <div class="input-group">
                    <input class="form-control diy-bind color" type="color" data-bind-child="style" data-bind="background" value="<%style.background%>" />
                    <span class="input-group-addon btn btn-default" onclick="$(this).prev().val('#000000').trigger('propertychange')">重置</span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">背景透明度</div>
            <div class="col-sm-9">
                <div class="form-group">
                    <div class="slider col-sm-8 " data-value="<%style.opacity%>" data-min="0" data-max="10" data-decimal="10"></div>
                    <div class="col-sm-9 control-labe count"><span><%style.opacity%></span>(最大是1)</div>
                    <input class="diy-bind input" data-bind-child="style" data-bind="opacity" value="<%style.opacity%>" type="hidden" />
                </div>
            </div>
        </div>
    <%/if%>

    <div class="form-group">
        <div class="col-sm-2 control-label">显示设置</div>
        <div class="col-sm-9">
            <label class="radio-inline"><input type="radio" name="showtype" value="0" class="diy-bind" data-bind-child="params" data-bind="showtype" data-bind-init="true" <%if params.showtype==0%>checked="checked"<%/if%>>每次显示</label>
            <label class="radio-inline"><input type="radio" name="showtype" value="1" class="diy-bind" data-bind-child="params" data-bind="showtype" data-bind-init="true" <%if params.showtype==1%>checked="checked"<%/if%>>间隔时间显示</label>
        </div>
    </div>

    <%if params.showtype==1%>
        <div class="form-group">
            <div class="col-sm-2 control-label">间隔时间</div>
            <div class="col-sm-9">
                <div class="form-group">
                    <div class="slider col-sm-8" data-value="<%params.showtime||60%>" data-min="1" data-max="240"></div>
                    <div class="col-sm-9 control-labe count"><span><%params.showtime||1%></span>分钟</div>
                    <input class="diy-bind input" data-bind-child="params" data-bind="showtime" value="<%params.showtime||60%>" type="hidden" />
                </div>
            </div>
        </div>
    <%/if%>

    <div class="line"></div>

    <div class="form-items indent" data-min="1" data-max="5">
        <div class="alert alert-warning">添加多个将以轮播图形式展现；广告图片建议尺寸500*600</div>
        <div class="inner" id="form-items">
            <%each data as item itemid %>
                <div class="item" data-id="<%itemid%>">
                    <span class="btn-del del-item" title="删除"></span>
                    <div class="item-body">
                        <div class="item-image drag-btn square" style="height: 110px; line-height: 110px;">
                            <img src="<%imgsrc item.imgurl%>" onerror="this.src='../addons/{MODULE_NAME}/web/resource/images/nopic.png';" id="pimg-<%itemid%>" style="background: #fff; height: 100%; width: 100%" />
                        </div>
                        <div class="item-form">
                            <div class="input-group" style="margin-bottom:0px;">
                                <input type="text" class="form-control diy-bind" data-bind-parent="<%itemid%>" data-bind-child="data" data-bind="imgurl" data-bind-init="true" id="cimg-<%itemid%>" placeholder="请选择图片或输入图片地址" value="<%item.imgurl%>" />
                                <span class="input-group-addon btn btn-default" data-toggle="selectAttachment" data-input="#cimg-<%itemid%>" data-img="#pimg-<%itemid%>">选择图片</span>
                                <span class="input-group-addon btn btn-default selectGoods" itemid="<%itemid%>">选择商品</span>
                            </div>
                            <div class="input-group" style="margin-top:10px; margin-bottom:0px; ">
                                <span class="input-group-addon">点击事件</span>
                                <span class="form-control" style="padding-top: 0;">
                                    <label class="radio-inline"><input type="radio" name="click-<%itemid%>" value="0" class="diy-bind"  data-bind-parent="<%itemid%>" data-bind-child="data" data-bind="click" data-bind-init="true" <%if item.click=='0'%>checked="checked"<%/if%>>跳转链接</label>
                                    <label class="radio-inline"><input type="radio" name="click-<%itemid%>" value="1" class="diy-bind"  data-bind-parent="<%itemid%>" data-bind-child="data" data-bind="click" data-bind-init="true"<%if item.click=='1'%>checked="checked"<%/if%>>关闭广告</label>
                                </span>
                            </div>
                            <div class="input-group" style="margin-top:10px; margin-bottom:0px; ">
                                <input type="text" class="form-control diy-bind" readonly="readonly"  data-bind-parent="<%itemid%>" data-bind-child="data" data-bind="linkurl" id="curl-<%itemid%>" placeholder="请选择链接或输入链接地址" value="<%item.linkurl%>" <%if item.click=='1'%>disabled<%/if%> />
                                <span class="input-group-addon btn <%if item.click=='0'%>btn-default<%else%>btn-disabled<%/if%>" <%if item.click=='0'%>data-toggle="selectUrl" data-input="#curl-<%itemid%>"<%/if%>>选择链接</span>
                            </div>
                        </div>
                    </div>
                </div>
            <%/each%>
        </div>
        <div class="btn btn-w-m btn-block btn-default btn-outline" id="addItem"><i class="fa fa-plus"></i> 添加一个</div>
    </div>

</script>
<!--------------------------  弹框模板组件群  ----------------------------------->
<!--商品选择模板-->
<div class="modal fade" id="SelectGoodsContent" aria-hidden="false"></div>
<script type="text/html" id="tplSelectGoods">
    <div class="modal-dialog" style="min-width: 60%!important;">
        <div class="modal-content">
            <div class="modal-header">
                <button data-dismiss="modal" class="close" type="button">×</button>
                <h4 class="modal-title">
                    请选择
                    <%if plugin == 1%>
                    抢购商品
                    <%else if plugin == 2%>
                    团购商品
                    <%else if plugin == 3%>
                    拼团商品
                    <%else if plugin == 4%>
                    大礼包
                    <%else if plugin == 5%>
                    卡券
                    <%else if plugin == 6%>
                    折扣卡
                    <%else if plugin == 7%>
                    砍价商品
                    <%else if plugin == 9%>
                    同城活动
                    <%else%>
                    商品
                    <%/if%>
                </h4>
            </div>
            <div class="modal-body form-horizontal">
                <!--搜索-->
                <div class="form-group">
                    <div class="col-sm-9 searchContent">
                        <input class="form-control" placeholder="请输入商品名称..." value="<%search%>"/>
                    </div>
                    <div class="btn btn-primary goodsSelect" data-plugin="<%plugin%>">搜索</div>
                </div>
                <!--表格-->
                <div class="app-table-list">
                    <div class="panel panel-default">
                        <table class="table table-hover table-responsive table-bordered" style="border: 1px solid #e5e5e5;">
                            <thead>
                            <tr>
                                <th class="text-center" width="10%"><%if plugin == 4 || plugin == 6 %>店铺logo<%else%>图片<%/if%></th>
                                <th class="text-center" width="<%if plugin == 4 || plugin == 6 %>25<%else%>40<%/if%>%"><%if plugin == 4 || plugin == 6 %>店铺名称<%else%>名称<%/if%></th>
                                <th class="text-center" width="<%if plugin == 4 || plugin == 6 %>25<%else%>10<%/if%>%"><%if plugin == 4%>礼包名称<%else if plugin == 6%>折扣卡名称<%else%>类型<%/if%></th>
                                <%if plugin != 6%><th class="text-center" width="10%"><%if plugin == 4%>使用次数<%else%>状态<%/if%></th><%/if%>
                                <th class="text-center" width="10%"><%if plugin == 4%>礼包价值<%else if plugin == 6%>折扣信息<%else%>价格<%/if%></th>
                                <%if plugin != 6%><th class="text-center" width="10%">库存</th><%/if%>
                                <th class="text-center" width="10%">操作</th>
                            </tr>
                            </thead>
                            <tbody class="text-center">
                            <%each goods as val key%>
                            <tr>
                                <td class="text-center">
                                    <img src="<%val['logo']%>" />
                                </td>
                                <td class="text-left"><%if plugin == 4 || plugin == 6 %><%val['storename']%><%else%><%val['goods_name']%><%/if%></td>
                                <td class="<%if plugin == 4 || plugin == 6%>text-left<%else%>text-center<%/if%>">
                                    <%if plugin == 4 || plugin == 6 %>
                                    <%val['name']%>
                                    <%else%>
                                    <%if val['plugin'] == 'rush'%>
                                    抢购
                                    <%else if val['plugin'] == 'groupon'%>
                                    团购
                                    <%else if val['plugin'] == 'wlfightgroup'%>
                                    拼团
                                    <%else if val['plugin'] == 'coupon'%>
                                    卡券
                                    <%else if val['plugin'] == 'bargain'%>
                                    砍价
                                    <%else if val['plugin'] == 'activity'%>
                                    同城活动
                                    <%/if%>
                                    <%/if%>
                                </td>
                                <%if plugin != 6%>
                                <td>
                                    <%if plugin == 4%>
                                        <%val['usetimes']%>次
                                        <%if val['datestatus'] == 2%>/ 周
                                        <%else if val['datestatus'] == 3%>/ 月
                                        <%else if val['datestatus'] == 4%>/ 年<%/if%>
                                    <%else%>
                                        <%if val['plugin'] == 'rush'%>
                                            <%if val['status'] == 3%>
                                                <span class="label label-default">已结束</span>
                                            <%else%>
                                                <span class="label label-success">正常</span>
                                            <%/if%>
                                        <%else if val['plugin'] == 'groupon'%>
                                            <%if val['status'] == 3%>
                                                <span class="label label-default">已结束</span>
                                            <%else%>
                                                <span class="label label-success">正常</span>
                                            <%/if%>
                                        <%else if val['plugin'] == 'wlfightgroup'%>
                                            <span class="label label-success">正常</span>
                                        <%else if val['plugin'] == 'coupon'%>
                                            <span class="label label-success">正常</span>
                                        <%else if val['plugin'] == 'bargain'%>
                                            <%if val['status'] == 1%>
                                                <span class="label label-warning">未开始</span>
                                            <%else if val['status'] == 2%>
                                                <span class="label label-success">进行中</span>
                                            <%else%>
                                                <span class="label label-default">已结束</span>
                                            <%/if%>
                                        <%else if val['plugin'] == 'activity'%>
                                            <%if val['status'] == 1%>
                                                <span class="label label-warning">未开始</span>
                                            <%else if val['status'] == 2%>
                                                <span class="label label-success">进行中</span>
                                            <%else%>
                                                <span class="label label-default">已结束</span>
                                            <%/if%>
                                        <%/if%>
                                    <%/if%>
                                </td>
                                <%/if%>
                                <td class="<%if plugin != 6%>text-left<%else%>text-center<%/if%>"><span style="color:#ff3333;"><%if plugin != 6%>￥:<%else%><%val['discount']%><%if val['discount'] != '暂不可用'%>折<%/if%><%/if%></span><%if plugin != 6%><%val['price']%><%/if%></td>
                                <%if plugin != 6%>
                                <td><%val['stk']%></td>
                                <%/if%>
                                <td>
                                    <a href="javascript:;" class="btn btn-sm btn-warning selectGoods" data-key="<%key%>" data-keys="<%keys%>">选择</a>
                                </td>
                            </tr>
                            <%/each%>
                            </tbody>
                        </table>
                    </div>
                    <div class="paging"></div>
                </div>
            </div>
            <div class="modal-footer">
                <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
            </div>
        </div>
    </div>
</script>


